Opening Streams in an AVI File and Closing the File

The following example opens all the streams in an AVI file using the AVIFileGetStream30UP5VP function. If an error is encountered, the file is closed.

// InsertAVIFile - opens the streams in an AVI file.

//

// pfile - file-interface pointer from AVIFileOpen

//

// Global variables

// gcpavi - count of the number of streams in an AVI file

// gapavi[] = array of stream-interface pointers

 

void InsertAVIFile(PAVIFILE pfile, HWND hwnd, LPSTR lpszFile)

    int    i;

    gcpavi = 0;

 

    // Open the streams until a stream is not available.

    for (i = gcpavi; i < MAXNUMSTREAMS; i++) { 

        gapavi[i] = NULL;

        if (AVIFileGetStream(pfile, &gapavi[i], 0L, i - gcpavi)
            != AVIERR_OK)

        break;

 

    if (gapavi[i] == NULL)

        break;

    }

    // Display error message-stream not found.

    if (gcpavi == i)

   

        ErrMsg("Unable to open %s", lpszFile);

        if (pfile) // If file is open, close it

        AVIFileRelease(pfile);

        return;

    }

    else { 

        gcpavi = i - 1;

    }

 

//  .

//  . Place functions to process data here.

//  .

}